﻿@using Kunlun.BusinessLogic;
@using Kunlun.Models;
@model List<Kunlun.Models.Product>
@{
    ViewBag.Title = "商品列表";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section Head{
<link href="@Url.Content("~/Content/search/StyleSheet.css")" type="text/css" rel="Stylesheet" />
}
<div id="content">
	<div id="left1">
		<div class="Alldiv div1">
			<p>
				<a href="?">全部分类</a>
				@foreach (Category ci in ViewData["TreeCate"] as List<Category>)
        {
					<span>></span>  <a href="?Classid=@ci.ID">@ci.Cname</a>
        }</p>
			<dl>
				@if (ViewData["Cates"] != null)
        {
        foreach (Category c in ViewData["Cates"] as List<Category>)
            {
					<dd>
					@Html.ActionLink(c.Cname, "Search", new { @Classid = c.ID })
						</dd>
            }

        }</dl>
		</div>
		<div class="Alldiv div2">
				<dl>
					<dt>风格：</dt>
				@foreach (Category c in ViewData["HisCates"] as List<Category>)
        {
        if (Request.QueryString["f"] == c.ID.ToString())
            {
			<dd class="sel">@Html.ActionLink(c.Cname, "Search", new { @list = Request.QueryString["list"], @Classid = Request.QueryString["Classid"] })</dd>
            }
        else
            {
			<dd>@Html.ActionLink(c.Cname, "Search", new { @f = c.ID, @list = Request.QueryString["list"], @Classid = Request.QueryString["Classid"] })</dd>
            }
        }
				</dl>
				</div>
		<dl class="newShow">
			<dd class="showFont">
				显示方式：</dd>
			<dd class="showImg">
				@{
                    string str = string.Empty;
                    foreach (string key in Request.QueryString)
                        {
                        if (key != "list" && !string.IsNullOrEmpty(key))
                            {
                            str += key + "=" + Request.QueryString[key] + "&";
                            }
                        }
				}
				<input type="button" class="list@(Request.QueryString["list"] == "0" || string.IsNullOrEmpty(Request.QueryString["list"]) ? 1 : 0)" title="图文方式" onclick="location.href='?list=0&@str'"  />
				<input type="button" class="text@(Request.QueryString["list"] == "1" ? 1 : 0)" title="图屏方式" onclick="location.href='?list=1&@str'" />
			<dd>
			</dd>
			<dd class="orderFont">
				排序方式：</dd>
			<dd class="showImg">
				@{
                    str = string.Empty;
                    foreach (string key in Request.QueryString)
                        {
                        if (key != "sort" && !string.IsNullOrEmpty(key))
                            {
                            str += key + "=" + Request.QueryString[key] + "&";
                            }
                        }
				}
				<input type="button" class="buy@(Request.QueryString["sort"] == "1" ? 1 : 0)" title="销量高到低" onclick="location.href='?sort=1&@str'" />
				<input type="button" class="mt@(Request.QueryString["sort"] == "2" ? 1 : 0)" title="价格低到高" onclick="location.href='?sort=2&@str'" />
				<input type="button" class="mb@(Request.QueryString["sort"] == "3" ? 1 : 0)" title="价格高到低" onclick="location.href='?sort=3&@str'" />
			</dd>
			<dd class="orderFont">
				关键字：</dd>
			<dd>
				<input type="text" class="input" value='@Request.QueryString["Name"]' id="SearchKey" /></dd>
			<dd>
				<input type="button" class="button" value="搜索" onclick="if(document.getElementById('SearchKey').value.length > 0){location.href='?Name='+escape(document.getElementById('SearchKey').value);}else{alert('请输入要搜索的关键字！');}" /></dd>
		</dl>
		<div id="ajaxcontent">
			@{if (Request.QueryString["list"] == "0" || string.IsNullOrEmpty(Request.QueryString["list"]))
         {
         
         	<div class="list-y">
					@foreach (Product p in Model)
         {
						<dl>
							<dt><a href="@Url.Action("Views", "Frame", new { id = p.pid })">
								<img onload="DrawImage(this,184,184)" src='@string.Format("{0}{1}", WebLog.ImageHttp, Kunlun.BusinessLogic.ProductImageToThum.Thumbnail(p.ViewPic))' alt='@p.Name' /></a></dt>
							<dd>
								<a href="@Url.Action("Views", "Frame", new { id = p.pid })">@p.Name</a></dd>
							<dd class='say'>
								评论0条</dd><dd class='money'>
									￥@string.Format("{0:F}", p.Kacaprice)</dd>
						</dl>
         }
				</div>
         }
     else
         {
         foreach (Product p in Model)
             {
		  
				<div class="list-x">
					<div class="list-x-left">
						<a href="@Url.Action("Views", "Frame", new { id = p.pid })">
							<img src='@string.Format("{0}{1}", WebLog.ImageHttp, Kunlun.BusinessLogic.ProductImageToThum.Thumbnail(p.ViewPic))' alt='@p.Name' onload="DrawImage(this,184,184)" /></a>
					</div>
					<div class="list-x-right">
						<div style="float: left; width: 435px; height: 183px">
							<div class="list-x-title">
								<a href="@Url.Action("Views", "Frame", new { id = p.pid })">
									@p.Name</a></div>
							<ul class="zdysx">
							</ul>
						</div>
						<div class="list-x-price">
							<span>售价：@string.Format("{0:F}", p.Kacaprice)</span>
							<p>
								原价：@string.Format("{0:F}", p.Kacaprice * (decimal)2)</p>
							<p>
								共有<b>0</b>条评论</p>
							<p>
								<input type="button" class="buy" onclick="window.open('/Store/Frame/Views/@p.pid')" />
								@*<input type="button" class="shou" onclick="Collect('@p.pid')" />*@
							</p>
						</div>
					</div>
				</div>
				
             }
         }
			}
		</div>
	</div>
	<div id="right1">
		@Html.Action("ReadHisCookie")
	</div>
	<ul class='right_ye'>
		@{
            str = string.Empty;
            foreach (string key in Request.QueryString)
                {
                if (key != "index" && !string.IsNullOrEmpty(key))
                    {
                    str += key + "=" + Request.QueryString[key] + "&";
                    }
                }
            int index = (int)ViewData["Index"];
            int size = 10;
            int count = (int)ViewData["GoodsCount"];
            int countPage = count / size + (count % size > 0 ? 1 : 0);

            if (index > 0)
                {
			<li><a href='?index=@(index - 1)&@str'>上一页</a></li>
                }
            else
                {
			<li>上一页</li>
                }
            int pageIndex = (index - 3 >= 0) ? index - 3 : 0;
            if (pageIndex != 0)
                {
			<li class='page'><a href='?index=@(pageIndex - 1)&@str'><</a></li>
                }

            for (int i = 0; pageIndex < countPage && i < 7; i++, pageIndex++)
                {
                if (pageIndex == index)
                    {
			<li class='indexpage'>@(pageIndex + 1)</li>
                    }
                else
                    {
			<li class='page'><a href='?index=@pageIndex&@str'>@(pageIndex + 1)</a></li>
                    }
                }
            if (pageIndex < countPage)
                {
			<li class='page'><a href='?index=@(pageIndex + 1)&@str'>></a></li>
                }
            if (index < countPage - 1)
                {
			<li><a href='?index=@(index + 1)&@str'>下一页</a></li>
                }
            else
                {
			<li>下一页</li>
                }
			<li class='pageStyle'>共 @count 件商品</li>
		}
	</ul>
</div>
